const mysql = require('mysql');

function myQuery(sql){
    let conn = mysql.createConnection({
        host:'localhost',
        port: 3306,
        user:'root',
        password:'root',
        database:'xiaou'
    })
    
    conn.connect();


    return new Promise((resolve, reject)=>{
        conn.query(sql, (err, result)=>{
            resolve([err, result]);
        })
        conn.end();
    })
}

module.exports = myQuery;